<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 计算属性</title>
    <script src="../../vue文件/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="a++">修改a {{a}}</button>
       <!-- <p>{{msg.split('').reverse().join('')}}</p> -->
       <p>{{fz}}</p>
       <div>
           商品单价：<input type="text" v-model.number="price">
       </div>
       <div>
           商品数量：<input type="text" v-model.number="num">
       </div>
       <div>
           总价：<span>{{res}}</span>
       </div>
       <div>
           总价：<span>{{res}}</span>
       </div>
       <div>
           总价：<span>{{res}}</span>
       </div>
       <div>
           总价：<span>{{res}}</span>
       </div>
       <div>
           总价：<span>{{res}}</span>
       </div>
       <div>
           方法计算总价：<span>{{totalPrice()}}</span>
       </div>
       <div>
           方法计算总价：<span>{{totalPrice()}}</span>
       </div>
       <div>
           方法计算总价：<span>{{totalPrice()}}</span>
       </div>
       <div>
           方法计算总价：<span>{{totalPrice()}}</span>
       </div>
       <div>
           方法计算总价：<span>{{totalPrice()}}</span>
       </div>
    </div>
</body>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            msg:'hello',
            price:0,
            num:0,
            a:0
        },
        methods: {
            totalPrice(){
                console.log('方法');
                return this.price*this.num
            }
        },
        // 计算属性
        computed: {
            fz(){
                return this.msg.split('').reverse().join('')
            },
            res(){
                console.log('计算属性。。。');
                return this.price*this.num
            }
        },
        
    })
</script>
</html>